package com.peycash.monitoring.fachada.impl;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.peycash.monitoring.fachada.PendientesFachada;
import com.peycash.monitoring.servicio.ClientesPendientesServicio;
import com.peycash.monitoring.servicio.SMSServicio;
import com.peycash.monitoring.servicio.ServicioException;

@Component
public class PendientesFachadaImpl implements PendientesFachada{

	@Autowired
	private ClientesPendientesServicio servicioPendientes;
	@Autowired
	private SMSServicio servicioSMS;
	
	private Logger LOGGER = LoggerFactory.getLogger(PendientesFachadaImpl.class);
	
	@Override
	@Scheduled(cron = "*/30 * * * * ?")
	public void update(){
		try {
			List<String> numsPendientes = servicioPendientes.findPendientes();
			for(String s: numsPendientes){
				servicioSMS.updateSmsClienteRegistrado(s);
			}
		} catch (ServicioException e) {
			LOGGER.error("Erroe en update:"+e.getMessage(), e);
		}
	}
}
